Skip to content

Add Prettier to keep things consistent #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 26, 2025
Merged

Add Prettier to keep things consistent #115

merged 5 commits into from
Jul 26, 2025

Conversation

kraenhansen
Copy link
Collaborator

@kraenhansen kraenhansen commented Jun 8, 2025

Merging this PR will:

  • Introduce the prettier CLI and two package scripts for the root package, one to check and one to write (/ fix).

@kraenhansen kraenhansen self-assigned this Jun 8, 2025
Copy link

changeset-bot bot commented Jun 8, 2025

⚠️ No Changeset found

Latest commit: f18f6cc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@kraenhansen
Copy link
Collaborator Author

The check seems to work on CI 👍 I'll rebase this and commit the result of running prettier:write once we have a couple of other PRs merged 🤞

Copy link
Collaborator

@shirakaba shirakaba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just some suggestions!

.prettierignore Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to do the trick. I've tried entering various gitignored folders with "format on save" enabled and it successfully ignores them. It seems node_modules is implicitly ignored as well. 👍

I'm hoping to get permission to opensource a tool I made at work that flattens all .gitignores under a tree into a single one – I made it specifically to support Prettier, which has spent years neglecting monorepo support. But let's not wait on that.

Comment on lines 20 to +29
- run: npm run lint
- run: npm run prettier:check
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- run: npm run lint
- run: npm run prettier:check
- run: node --run lint
- run: node --run prettier:check

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I plan to do a separate PR to update npm run across the repo 👍 Especially when calling other scripts within scripts.

package.json Outdated
"globals": "^16.0.0",
"prettier": "3.5.3",
Copy link
Collaborator

@shirakaba shirakaba Jul 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's upgrade this to Prettier 3.6 (see blog post).

package.json Outdated
Comment on lines 16 to 17
"prettier:check": "prettier --check .",
"prettier:write": "prettier --write .",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Prettier 3.6, we can use the performance-improved CLI.

Suggested change
"prettier:check": "prettier --check .",
"prettier:write": "prettier --write .",
"prettier:check": "prettier --experimental-cli --check .",
"prettier:write": "prettier --experimental-cli --write .",

.prettierrc Outdated
@@ -0,0 +1 @@
{}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest renaming to prettier.config.mjs for some Intellisense and adding @prettier/plugin-oxc for mad speed, which was announced alongside Prettier 3.6.

After running:

npm add -D prettier@latest @prettier/plugin-oxc
Suggested change
{}
/**
* @satisfies {import("prettier").Config}
* @see https://prettier.io/docs/en/configuration.html
*/
const config = {
plugins: ["@prettier/plugin-oxc"],
};
export default config;

@kraenhansen kraenhansen marked this pull request as ready for review July 26, 2025 08:18
@kraenhansen kraenhansen merged commit 9b231c1 into main Jul 26, 2025
6 checks passed
@kraenhansen kraenhansen deleted the kh/prettier branch July 26, 2025 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants